package com.lagou.edu.user.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.lagou.edu.user.dto.WeixinDTO;
import com.lagou.edu.user.entity.Weixin;
import com.lagou.edu.user.mapper.WeixinMapper;
import com.lagou.edu.user.service.IWeixinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LiuQiang
 * @since 2021-08-25
 */
@Service
public class WeixinServiceImpl extends ServiceImpl<WeixinMapper, Weixin> implements IWeixinService {

    @Override
    public WeixinDTO queryOne(LambdaQueryWrapper<Weixin> wrapper) {
        List<Weixin> weixins = this.baseMapper.selectList(wrapper);
        if (CollectionUtils.isEmpty(weixins)) {
            return null;
        }
        WeixinDTO dto = new WeixinDTO();
        BeanUtil.copyProperties(weixins.get(0), dto);
        return dto;
    }


}
